﻿// author: Yin Zhu
// this file is part of SharpMiner

namespace SharpMiner.Utility

module Profile = 
    type Watcher() = 
        let stopWatch = new System.Diagnostics.Stopwatch()
        member m.tic() = 
            stopWatch.Reset()
            stopWatch.Start()
        member m.toc() = 
            stopWatch.Stop()
            printfn "passed: %f ms" stopWatch.Elapsed.TotalMilliseconds
            stopWatch.Reset()
            stopWatch.Start()
        member m.toc(msg) = 
            stopWatch.Stop()
            printfn "%s: %f ms" msg stopWatch.Elapsed.TotalMilliseconds
            stopWatch.Reset()
            stopWatch.Start()

    let getWatch() = new Watcher()


    let private stopWatch = getWatch()
    let tic() = stopWatch.tic()
    let toc(msg:string) = stopWatch.toc(msg)

